package org.example;

import java.util.Stack;

public class StackApp {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();

        // O(1)
        stack.push(1);
        stack.push(2);
        stack.push(2);

        // 获取栈顶元素 O(1)
        stack.peek();

        // 删除栈顶元素  O(1)
        stack.pop();

        // O(1)
        stack.size();

        // O(1)
        stack.isEmpty();

        // 遍历 O(N)
        while (!stack.isEmpty()) {
            int a = stack.pop();
            System.out.println(a);
        }

    }
}
